package com.czy.owner.api;

import android.text.TextUtils;

import com.czy.owner.net.api.BaseApi;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.czy.owner.utils.MyLog;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

import java.util.HashMap;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by asus on 2017/6/5.
 */

public class AddCartApi extends BaseApi {
    private String session;
    private String goodsId;
    private String specGroupKey;
    private String count;
    private String serviceInstallStoreId;
    private String deliveryWayId;
    private String needService;
    private String shoppingCartId;
    private String fromType;
    private String fromTypeId;

    public String getFromType() {
        return fromType;
    }

    public void setFromType(String fromType) {
        this.fromType = fromType;
    }

    public String getFromTypeId() {
        return fromTypeId;
    }

    public void setFromTypeId(String fromTypeId) {
        this.fromTypeId = fromTypeId;
    }

    public String getShoppingCartId() {
        return shoppingCartId;
    }

    public void setShoppingCartId(String shoppingCartId) {
        this.shoppingCartId = shoppingCartId;
    }

    public String getNeedService() {
        return needService;
    }

    public void setNeedService(String needService) {
        this.needService = needService;
    }

    public AddCartApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity) {
        super(listener, rxAppCompatActivity);
        setCache(true);
        setCookieNetWorkTime(0);
        setShowProgress(true);
    }

    public String getSession() {
        return session;
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getSpecGroupKey() {
        return specGroupKey;
    }

    public void setSpecGroupKey(String specGroupKey) {
        this.specGroupKey = specGroupKey;
    }

    public String getCount() {
        return count;
    }

    public void setCount(String count) {
        this.count = count;
    }


    public String getServiceInstallStoreId() {
        return serviceInstallStoreId;
    }

    public void setServiceInstallStoreId(String serviceInstallStoreId) {
        this.serviceInstallStoreId = serviceInstallStoreId;
    }

    public String getDeliveryWayId() {
        return deliveryWayId;
    }

    public void setDeliveryWayId(String deliveryWayId) {
        this.deliveryWayId = deliveryWayId;
    }

    public void setSession(String session) {
        this.session = session;
    }

    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        HashMap<String, Object> map = new HashMap<>();
        map.put("session", getSession());
        map.put("goodsId", getGoodsId());
        map.put("count", getCount());
        map.put("needService", getNeedService());
        if (!TextUtils.isEmpty(getSpecGroupKey())) {
            map.put("specGroupKey", getSpecGroupKey());
        }
        if (!TextUtils.isEmpty(getShoppingCartId())) {
            map.put("shoppingCartId", getShoppingCartId());
        }
        if (!TextUtils.isEmpty(getServiceInstallStoreId())) {
            map.put("serviceInstallStoreId", getServiceInstallStoreId());
        }
        if (!TextUtils.isEmpty(getDeliveryWayId())) {
            map.put("deliveryWayId", getDeliveryWayId());
        }


        if(!TextUtils.isEmpty(getFromType())){
            map.put("fromType",getFromType());
        }
        if(!TextUtils.isEmpty(getFromTypeId())){
            map.put("fromTypeId",getFromTypeId());
        }
        MyLog.e("yang","加入购物车成功=="+map.toString());
        return service.getModifyCart(map);
    }
}
